package generic.gui.util;

import java.awt.Component;

import javax.swing.ImageIcon;
import javax.swing.JTree;
import javax.swing.tree.DefaultTreeCellRenderer;
import javax.swing.tree.TreeCellRenderer;

@SuppressWarnings("serial")
public class DefaultTreeCellRendererForm extends DefaultTreeCellRenderer implements TreeCellRenderer {
	
	private ImageIcon raiz;
	private ImageIcon defaultIcon;
	
	public DefaultTreeCellRendererForm(ImageIcon raiz) {
		this(raiz, null);
	}
	public DefaultTreeCellRendererForm(ImageIcon raiz, ImageIcon defaultIcon) {
		super();
		setRaiz(raiz);
		setDefaultIcon(defaultIcon);
	}

	@Override
	public Component getTreeCellRendererComponent(JTree tree, Object value, boolean selected, boolean expanded, boolean leaf, int row, boolean hasFocus) {

		super.getTreeCellRendererComponent(tree, value, selected, expanded, leaf, row, hasFocus);

		if(row == 0)
			setIcon(getRaiz());
		else
			setIcon(getDefaultIcon());

		return this;

	}

	public ImageIcon getRaiz() {
		return raiz;
	}

	public void setRaiz(ImageIcon raiz) {
		this.raiz = raiz;
	}

	public ImageIcon getDefaultIcon() {
		return defaultIcon;
	}

	public void setDefaultIcon(ImageIcon defaultIcon) {
		this.defaultIcon = defaultIcon;
	}
	
}
